{template member/header.html}
<script type="text/javascript">
    function usernameFocus() {
        document.getElementById("username_prompt").innerHTML = "请输入登录账号";
    }
    function pwdFocus() {
        document.getElementById("pwd_prompt").innerHTML = "密码可由大小写英文字母、数字组成，长度6-20个字符";
    }
    function repwdFocus() {
        document.getElementById("repwd_prompt").innerHTML = "请再次输入您的密码";
    }
    function emailFocus() {
        document.getElementById("email_prompt").innerHTML = "请输入您的电子邮箱地址";
    }

    function usernameBlur() {
        var username = document.getElementById("inputUsername");
        var prompt = document.getElementById("username_prompt");
        prompt.innerHTML = "";
        if (username.value == "") {
            prompt.innerHTML = "请输入您的登陆账号";
            return false;
        }
        if (/^[a-zA-Z0-9_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]+$/.test(username.value) == false) {
            prompt.innerHTML = "登陆账号格式不正确，请重新输入";
            return false;
        }
    }
    function emailBlur() {
        var email = document.getElementById("inputEmail");
        var promptId = document.getElementById("email_prompt");
        promptId.innerHTML = "";
        var reg = /^[a-z0-9&\-_.]+@[\w\-_]+([\w\-.]+)?\.[\w\-]+$/;
        if (email.value == "") {
            promptId.innerHTML = "请输入您的电子邮箱";
            return false;
        }
        if (reg.test(email.value) == false) {
            promptId.innerHTML = "电子邮件格式不正确，请重新输入";
            return false;
        }
        $.post('{function.url("api/member/ajaxemail")}&' + Math.random(), {
            email: email.value
        }, function (data) {
            console.log(data);
            promptId.innerHTML = data.msg;
            return true;
        });
        return true;
    }
    function pwdBlur() {
        var pwd = document.getElementById("inputPwd");
        var prompt = document.getElementById("pwd_prompt");
        prompt.innerHTML = "";
        var reg = /^[a-zA-Z0-9]{6,20}$/;
        if (pwd.value == "") {
            prompt.innerHTML = "密码为必填项，请设置您的密码";
            return false;
        }
        if (reg.test(pwd.value) == false) {
            prompt.innerHTML = "密码格式错误，请用大小写英文字母、数字，长度6-20个字符";
            return false;
        }
        return true;
    }
    function repwdBlur() {
        var pwd = document.getElementById("inputPwd");
        var repwd = document.getElementById("inputRepwd");
        var prompt = document.getElementById("repwd_prompt");
        prompt.innerHTML = "";
        if (repwd.value == "") {
            prompt.innerHTML = "请再次输入密码予以确认";
            return false;
        }
        if (pwd.value != repwd.value) {
            prompt.innerHTML = "两次输入密码不一致，请重新输入";
            return false;
        }
        return true;
    }
    function checkRegister() {
        emailBlur();
        pwdBlur();
        repwdBlur();
        var flagEmail = emailBlur();
        var flagNickName = nickNameBlur();
        var flagPwd = pwdBlur();
        var flagRepwd = repwdBlur();
        if (flagEmail == true && flagPwd == true && flagRepwd == true) {
            return true;
        } else {
            return false;
        }
    }

    function reload_code() {
        document.getElementById('code').src = '{function.url("api/access/checkcode", array("width"=>80, "height"=>28))}&' + Math.random();
    }

    function checkLogin() {
        emailBlur();
        pwdBlur();
        var flagEmail = emailBlur();
        var flagPwd = pwdBlur();
        if (flagEmail == true && flagPwd == true) {
            return true;
        } else {
            return false;
        }
    }

    function unset_se() {
        unset($_SESSION['u_pwd']);
        unset($_SESSION['u_name']);
        alert("已退出");
    }
</script>

<form class="form form-horizontal" method="post" action="" name="myform" id="myform">
{if count($member_model)>1}
会员模型：<select name="data[modelid]">
{loop $member_model $t}
        <option value="{$t['modelid']}" {if $member_default_modelid==$t['modelid']}selected{/if}>{$t['modelname']}</option>
{/loop}
    </select>
{/if}
    <div class="form-group form-inline">
        <label class="control-label col-sm-2" for="inputUsername"><font color="red">*</font>登录账号</label>
        <div class="col-sm-10">
            <input class="form-control" type="text" name="data[username]" autocomplete="off" placeholder="登陆账号" id="inputUsername" onfocus="usernameFocus()" onblur="usernameBlur()" />
            <span id="username_prompt" class="tips_info"></span>
        </div>
    </div>
    <div class="form-group form-inline">
        <label class="control-label col-sm-2" for="inputPwd"><font color="red">*</font>登录密码</label>
        <div class="col-sm-10">
            <input class="form-control" type="text" name="data[password]" autocomplete="off" placeholder="登录密码" id="inputPwd" onfocus="pwdFocus()" onblur="pwdBlur()" />
            <span id="pwd_prompt" class="tips_info"></span>
        </div>
    </div>
    <div class="form-group form-inline">
        <label class="control-label col-sm-2" for="inputRepwd"><font color="red">*</font>确认密码</label>
        <div class="col-sm-10">
            <input class="form-control" type="text" name="data[password2]" autocomplete="off" placeholder="确认密码" id="inputRepwd" onfocus="repwdFocus()" onblur="repwdBlur()" />
            <span id="repwd_prompt" class="tips_info"></span>
        </div>
    </div>
    <div class="form-group form-inline">
        <label class="control-label col-sm-2" for="inputEmail">邮箱地址</label>
        <div class="col-sm-10">
            <input class="form-control" type="email" name="data[email]" autocomplete="off" placeholder="确认密码" id="inputEmail" onfocus="emailFocus()" onblur="emailBlur()" />
            <span id="email_prompt" class="tips_info"></span>
        </div>
    </div>
{if $config['MEMBER_REGCODE']}
    <div class="form-group form-inline">
        <label class="control-label col-sm-2" for="code"><font color="red">*</font>注册验证</label>
        <div class="col-sm-10">
            <input class="form-control" type="text" name="code" autocomplete="off" placeholder="输入验证码" style="width:100px" />
            <img id="code" title="看不清楚？换一张" align="absmiddle" onclick="reload_code();" src="{function.url('api/access/checkcode', array('width'=>80, 'height'=>28))}"  style="cursor:pointer; margin-top:-3px;" />
        </div>
    </div>
{/if}
    <div class="form-group form-inline">
        <label class="control-label col-sm-2">&nbsp;</label>
        <div class="col-sm-10">
            <button type="submit" class="btn btn-default" name="submit">提交注册</button>
        </div>
    </div>
</form>

{template footer.html}